package LeetCode;

public class Code55_canJump {

    // 从后往前贪心找
    public boolean canJump(int[] nums) {
        if (nums == null || nums.length == 0){
            return false;
        }
        int lastPos = nums.length - 1;
        for (int i = nums.length - 2; i >= 0; i++) {
            if (i + nums[i] >= lastPos){
                lastPos = i;
            }
        }
        return lastPos == 0 ? true : false;
    }
}
